package com.mapapp.flutter_mapapp.persenter;

import android.content.Context;
import android.util.Log;

import com.mapapp.flutter_mapapp.bean.MapDetailBean;
import com.mapapp.flutter_mapapp.bean.StepFloorBean;
import com.mapapp.flutter_mapapp.http.ActivityLifeCycleEvent;
import com.mapapp.flutter_mapapp.http.Api;
import com.mapapp.flutter_mapapp.http.HttpUtil;
import com.mapapp.flutter_mapapp.http.ProgressSubscriber;
import com.mapapp.flutter_mapapp.util.ToastUtils;
import com.mapapp.flutter_mapapp.view.StepListViewInterface;

import java.util.List;

import rx.subjects.PublishSubject;

public class StepListPersenter {
    private static final String TAG = "StepListPersenter";

    private Context mContext;
    private StepListViewInterface mView;
    private PublishSubject<ActivityLifeCycleEvent> lifecycleSubject;

    public StepListPersenter(Context context , StepListViewInterface view,PublishSubject<ActivityLifeCycleEvent> lifecycleSubject){
        this.mContext = context;
        this.mView = view;
        this.lifecycleSubject = lifecycleSubject;
    }

    public void getListInfo(String parentId){
        HttpUtil.getInstance().toSubscribe(Api.getApiService().getFloorInfo(parentId),
                new ProgressSubscriber<StepFloorBean>(mContext,false) {
                    @Override
                    protected void _onNext(StepFloorBean data) {
                        mView.showData(data);
                    }

                    @Override
                    protected void _onError(String message) {
                        if("无可用的户数据".equals(message)){
                            mView.noData();
                        }
                        ToastUtils.showMessage(mContext, message);
                    }
                }, lifecycleSubject);
    }
}
